﻿using System;
using System.Collections.Generic;
using EmailJabber.Logic.Commands.Base;
using EmailJabber.Logic;
using EmailJabber.EmailJabber.Core.Commands.Common;
using EmailJabber.Logic.Logic.BusinessLogic;


namespace FinancialPersonal.Commands
{
	/// <summary>
	/// Description of FinancialHelpCommnd.
	/// </summary>
	public class FinancialHelpCommnd: CommandBase
	{
		public static Guid FinanceTag = new Guid("1e50f00c-e414-45e6-bd07-38ba9a1dd5ad");
		
		public FinancialHelpCommnd()
    	{
    		States.States.Instance.Init();
            _aliaces =new[]{"помощь","?"};
    	}
    	
        protected override string GetDecription()
        {
            return "Return statistic for all goals.";
        }

        protected override Guid GetId()
        {
            return new Guid("1FC982DD-3191-4A00-A00B-BB02B09FC531");
        }

        protected override void ExecuteSafe(MessageIM comnd)
        {  
			string messBody = "All commands:" + Environment.NewLine;
			foreach (KeyValuePair<List<string>, Guid> pair in BL.Instance.BotCommands)
			{
				CommandBase currentCommand = CommandManager.Instance.GetCommand(pair.Value);
				if(!currentCommand.Tags.Contains(FinanceTag))
				{
					continue;
				}
				string aliases=string.Empty;
				foreach (string key in pair.Key)
				{
					aliases += key + "; ";
				}
				if(comnd.Body.Contains("id"))
				{
					messBody +=string.Format("{0}     : {1}", currentCommand.Id, currentCommand.Description)+Environment.NewLine;
					
				}
				else if(comnd.Body.Contains("l"))
				{
					messBody +=string.Format("{0}     : {1}      GUID: {2}", aliases, currentCommand.Description,currentCommand.Id)+Environment.NewLine;
				}				
				else
				{
					messBody +=string.Format("{0}     : {1}", aliases, currentCommand.Description)+Environment.NewLine;
				}				
			}
			MessageIM mess = new MessageIM(comnd.To,messBody,comnd.From);
			BL.Instance.Send(mess);
        }
	}
}
